package com.ftg.learn.controller;

import com.ftg.learn.service.Iuser;
import com.ftg.learn.util.ResultJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 登陆
 * @author kangjx
 * @date 2022/10/21
 */
@RestController
@Api(tags = "登陆模块")
@RequestMapping("/login")
public class LoginController {

    @Resource
    Iuser iuser;

    /**
     * 系统登陆功能
     * @param account 账号
     * @param password 密码
     * @return
     */
    @PostMapping("/checkUserForLogin")
    public ResultJson checkUser(
            @RequestParam(value = "account") @ApiParam(value = "帐号",required = true,example = "admin") String account,
            @RequestParam(value = "password") @ApiParam(value = "密码",required = true,example = "admin") String password
    ){
        return iuser.loginForUser(account, password);
    }

    /**
     * 判断当前给定的u_id具有哪些角色 ，以及角色具有全部权限
     * @param uid 用户的唯一标识
     */
    @GetMapping("/showProvilege")
    public ResultJson showProvilege(
            @RequestParam(value = "uid") @ApiParam(value = "用户编号",required = true,example = "1") Integer uid
    ){
        return iuser.showProvilegeWithUid(uid);
    }
}
